/////////////////////////////////////////////////////////////////////////////
// Name:        ax_activator_resource.h
// Purpose:     Resource activator classes
// Author:      Julian Smart
// Modified by:
// Created:     2009-03-20
// RCS-ID:
// Copyright:   (c) Julian Smart
// Licence:     New BSD License
/////////////////////////////////////////////////////////////////////////////

#ifndef _AX_ACTIVATOR_RESOURCE_H_
#define _AX_ACTIVATOR_RESOURCE_H_

/*!
 * Includes
 */

#include "ax/ax_activator.h" 

/*!
 * Styles and types
 */

/*!
 * Forward declarations
 */

class AxResourceLibrary;

/**
    @class AxResourceLibraryActivator

    This class supports various operations on the resource library,
    returning a menu of further categories or resources.

    @category{ax_resource}
 */

class AxResourceLibraryActivator: public AxActivator
{
public:
    
/**
    The type of search this activator should perform.
 */

    typedef enum {
        Search_Fields,
        Search_All
    } AxResourceLibraryActivatorType;

    DECLARE_DYNAMIC_CLASS( AxResourceLibraryActivator )

public:
// Constructors

    AxResourceLibraryActivator() { Init(); }
    AxResourceLibraryActivator(const AxResourceLibraryActivator& activator) { Init(); Copy(activator); }

    AxResourceLibraryActivator(AxMenuItem* item, AxResourceLibrary* library, AxResourceLibraryActivatorType type);
    AxResourceLibraryActivator(AxMenuItem* item, AxResourceLibrary* library, const wxArrayString& fields, const wxArrayString& values);
    ~AxResourceLibraryActivator() {}

// Operations

    void Init();

    void Copy(const AxResourceLibraryActivator& activator);

    virtual AxActivator* Clone() const { return new AxResourceLibraryActivator(*this); }

    virtual AxMenu* Activate(AxMenuController* controller, AxMenuItem* item);

    AxResourceLibraryActivatorType GetType() const { return m_type; }
    void SetType(AxResourceLibraryActivatorType type) { m_type = type; }

    AxResourceLibrary* GetLibrary() const { return m_library; }
    void SetLibrary(AxResourceLibrary* library) { m_library = library; }

protected:
    wxArrayString                   m_fields;
    wxArrayString                   m_values;

    AxResourceLibrary*              m_library;
    AxResourceLibraryActivatorType  m_type;

};

/**
  @class AxResourceActivator

  This is a generic resource activator class that takes an AxResource object
  and queries the AxModule objects for a suitable activator object,
  which it then stores for use within Activate and other functions.
  This saves the application code from doing the querying and creating
  an activator of the correct type.

  It's also a useful base class for activators that need to store
  a pointer to a AxResource and the AxResourceLibrary.
 */

class AxResourceActivator: public AxActivator
{
public:
    
    DECLARE_DYNAMIC_CLASS( AxResourceActivator )

public:
// Constructors

    AxResourceActivator() { Init(); }
    AxResourceActivator(const AxResourceActivator& activator) { Init(); Copy(activator); }

    AxResourceActivator(AxResourceLibrary* library, AxResource* resource);
    ~AxResourceActivator();

// Operations

    void Init();

    void Copy(const AxResourceActivator& activator);

    virtual AxActivator* Clone() const { return new AxResourceActivator(*this); }

    virtual AxMenu* Activate(AxMenuController* controller, AxMenuItem* item);

    /// Called when a menu is reactivated, for example by going up. This
    /// allows a view to be shown again, without generating all the menus.
    virtual bool Reactivate(AxMenuController* controller, AxMenuItem* item);

    /// Called when the user selects an item, for example to describe the item
    virtual bool Select(AxMenuController* controller, AxMenuItem* item);

    AxResource* GetResource() const { return m_resource; }
    void SetResource(AxResource* resource) { m_resource = resource; }

    AxResourceLibrary* GetLibrary() const { return m_library; }
    void SetLibrary(AxResourceLibrary* library) { m_library = library; }

    AxActivator* GetSpecificActivator() const { return m_specificActivator; }
    void SetSpecificActivator(AxActivator* activator) { m_specificActivator = activator; }

protected:
    AxResourceLibrary*  m_library;
    AxResource*         m_resource;
    AxActivator*        m_specificActivator;
};

#endif
    // _AX_ACTIVATOR_RESOURCE_H_
